package io.renren.wh.order.util;

import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * Groovy工具
 * 加载脚本
 */
public class GroovyUtil {

    private static ScriptEngineManager factory = new ScriptEngineManager();

    public static Invocable getInvocable(String script) throws ScriptException {
        ScriptEngine engine = factory.getEngineByName("groovy");
        engine.eval(script);
        return (Invocable) engine;
    }
}
